function Duck() {}
function Chicken() {}

var makeSound = function (animal) {
  if (animal instanceof Duck) {
    console.log("嘎嘎嘎");
  }
  if (animal instanceof Chicken) {
    console.log("咯咯咯");
  }
};

makeSound(new Duck());
makeSound(new Chicken());

// java多态
function Animal(name, sing) {
  this.name = name;
  this.sing = sing;
}

Animal.prototype.singing = function () {
  console.log(`我是 ${this.name}, ${this.sing}`);
};

var duck = new Animal("鸭子", "嘎嘎嘎");
var chicken = new Animal("公鸡", "咯咯咯");

duck.singing();
chicken.singing();
